#include <QApplication>
#include <QLocale>
#include <QTranslator>
#include <QDir>

#include "mainwindowimpl.h"
//
int main(int argc, char ** argv)
{
    QApplication app( argc, argv );

#ifdef Q_WS_WIN
    // To read/write the configuration file and the style file near the main file.
    QDir::setCurrent(QApplication::applicationDirPath());
#endif

    bool useTranslation = true;

    // Process command line
    if (argc > 1)
    {
        for (int i = 1; i < argc; i++)
        {
            if (QString(argv[i]) == "-notranslation")
                useTranslation = false;
            else
                useTranslation = true;
        }
    }

	QString locale;
	
	if (useTranslation)
		locale = QLocale::languageToString(QLocale::system().language());
	else
		locale = "";
		
    QTranslator translator;         
    translator.load(QString(":/translations/nagaina_") + locale);
    app.installTranslator(&translator);

    MainWindowImpl win;
    win.show();

    app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
    return app.exec();
}
